/*
 * @Author: your name
 * @Date: 2020-03-28 20:41:25
 * @LastEditTime: 2020-04-02 22:25:46
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \普联东文-未完成\js\index.js
 */
//banner
$('.index_banner').slick({
    autoplay: true,
    arrows: false,
    dots: false,
    infinite: true,
    speed: 0,
    autoplaySpeed: 4000,
    pauseOnHover: false,
    fade: true,
    responsive: [{
        breakpoint: 992,
        settings: {
            dots: true
        }
    }]
});




var beforeIndex = 0

$('.index_banner').init(function(slick) {
    var l = $("#index_main  .item").size();
    var firstDotDom = '<span class="active"></span>'
    var dotDom = '<span></span>';
    for (var i = 0; i < l; i++) {
        var emptyD = dotDom;
        if (i == 0) {
            emptyD = firstDotDom;
        }
        $('.index-dot').append(emptyD);
    }

    $('.index_banner .item.slick-current').addClass('active').siblings().removeClass('active');
})

$('.index_banner').on('beforeChange', function(slick, currentSlide) {
    beforeIndex = $('.index_banner').slick('slickCurrentSlide');
})

$('.index_banner').on('afterChange', function(slick, currentSlide) {
    $(".yy-copy-banner").remove();
    $('.index_banner .item.slick-current').addClass('active').siblings().removeClass('active');
    var _index = $('.index_banner').slick('slickCurrentSlide');
    $('.section1 .number span').eq(_index).addClass('active').siblings().removeClass('active');




    var $beforeBox = $('.index_banner .item:eq(' + beforeIndex + ')');
    var beforeSrc = $beforeBox.find('.scaleBg').css('background-image');
    var appendDom = '<div class="yy-copy-banner" style="background-image: ${beforeSrc};"></div>';
    var $currentBox = $(".scaleBg:nth(" + _index + ")");
    $currentBox.append(appendDom);

})


$(".section1").on("click", ".number span", function() {
    var _index = $(this).index();
    $('.index_banner').slick('slickGoTo', _index);
    $(this).addClass("active").siblings().removeClass("active");
})


$('.section1 .prev').click(function() {
    $('.index_banner').slick('slickPrev');
})
$('.section1 .next').click(function() {
    $('.index_banner').slick('slickNext');
});

// 默认小屏下显示单个图片滚动
var dvw = 1;
if ($('body').width() > 1600 || $('body').width() == 1024) {
    dvw = 2;
}
$('.swiper-content').slick({
    slidesToShow: dvw,
    slidesToScroll: 1,
    autoplay: true,
    autoplaySpeed: 2000,
    arrows: true,
    prevArrow: '.slick-prev',
    nextArrow: '.slick-next'
});
// $(function() {
//     $(".partner-ul li a").num6();
// })